import http from '../utils/http'

export const pageTeacherEnvs = (params) => http.get('/api/teacher/envs', { params })
export const createTeacherEnv = (data) => http.post('/api/teacher/envs', data)
export const getTeacherEnvById = (id) => http.get(`/api/teacher/envs/${id}`)
export const deleteTeacherEnv = (id) => http.delete(`/api/teacher/envs/${id}`)

export const listUsages = (environmentId, pageNum = 1, pageSize = 10) => http.get(`/api/teacher/envs/${environmentId}/usages`, { 
  params: { pageNum, pageSize } 
})
export const bindUsages = (environmentId, usages) => http.post(`/api/teacher/envs/${environmentId}/usages`, usages)
export const updateUsage = (usageId, data) => http.put(`/api/teacher/envs/usages/${usageId}`, data)
export const deleteUsage = (usageId) => http.delete(`/api/teacher/envs/usages/${usageId}`)
export const updateEnvStatus = (environmentId, status) => http.put(`/api/teacher/envs/${environmentId}/status`, null, { params: { status } })

export default {
  pageTeacherEnvs,
  createTeacherEnv,
  getTeacherEnvById,
  deleteTeacherEnv,
  listUsages,
  bindUsages,
  updateUsage,
  deleteUsage,
  updateEnvStatus,
}

